type MyQueue struct {
    Queue []int
}

func NewMyQueue() MyQueue {
    return MyQueue{
        Queue: make([]int, 0),
    }
}

func (this *MyQueue) Back () int {
    return this.Queue[len(this.Queue)-1]
}

func (this *MyQueue) Front() int {
    return this.Queue[0]
}

func (this *MyQueue) Empty() bool {
    return len(this.Queue) == 0
}

func (this *MyQueue) Push (val int) {
    for !this.Empty() && this.Back() < val {
        this.Queue = this.Queue[:len(this.Queue)-1]
    }
    this.Queue = append(this.Queue, val)
}

func (this *MyQueue) Pop (val int) {
    if !this.Empty() && this.Front() == val {
        this.Queue = this.Queue[1:]
    }
}

func maxSlidingWindow(nums []int, k int) []int {
    myQueue := NewMyQueue()
    ans := make([]int, 0)
    for i:=0; i<k; i++ {
        myQueue.Push(nums[i])
    }
    ans = append(ans, myQueue.Front())

    for i:=k ; i<len(nums); i++ {
        myQueue.Pop(nums[i-k])
        myQueue.Push(nums[i])
        ans = append(ans, myQueue.Front())
    }

    return ans
}